<%@ page import="com.work.bean.ClassW" %>
<%@ page import="java.util.List" %>
<%@ page import="com.work.entities.MyClass" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/10/7
  Time: 14:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>我的班级</title>
</head>
<%@include file="student_common.jsp" %>
<script>
    $(function () {
        $("#my_class_li").attr('class', 'active');
    });
</script>

<style>
    th, td {
        width: 160px;
        padding: 10px;
        background-color: rgb(180, 193, 224);
    }
</style>

<%
    List<MyClass> classes = (List<MyClass>) session.getAttribute("myClasses");

%>


<body>

<div>
    <div>
        <div style="margin-left: 250px">
            <h3 style="margin-top: 50px">所在班级</h3>

            <%



                if (classes.size() != 0) {
                    for (MyClass myClass : classes) {%>

            <center><span style="font-size: 25px">班级名称：<%=myClass.getClassName()%></span></center>
            <%
                }


            } else {
            %>

            <span>暂未加入任何班级</span>

            <center>
                <div style="margin-top: 80px">

                    <span>搜索加入：</span><input id="class_id" placeholder="请输入班级编号">
                    <button onclick="search()">搜索</button>
                </div>
            </center>
            <%
                }
            %>


        </div>

    </div>
</div>
<script>
    function search(){

        var value = $("#class_id").val();

        var re = /^[1-9]+[0-9]*]*$/;
        if (!re.test(value)) {
            alert("请输入纯数字");
        }else {
            window.location = "${pageContext.request.contextPath}/stu_add_class?classid="+value;
        }

    }
</script>
</body>
</html>
